﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace Communication.Tcp
{
    /// <summary>
    /// Represent Task that include also data
    /// </summary>
    class DataTask : Task
    {
        #region Ctor
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="type">The type of the task</param>
        /// <param name="client">The client requested the task</param>
        /// <param name="factory">The factory invoked the task</param>
        /// <param name="data">The data within the task</param>
        public DataTask(WorkType type, TcpClient client, TaskFactory factory, BufferedStream data)
            : base(type, client, factory)
        {
            this.m_data = data;
        }
        #endregion

        #region Methods
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            DataTask task_obj = obj as DataTask;
            if (task_obj == null)
                return false;
            return base.Equals((Task)task_obj) && this.m_data.Equals(task_obj.m_data);
        }
        #endregion

        #region Properties
        public BufferedStream Data
        {
            get
            {
                return this.m_data;
            }
        }
        #endregion

        #region Fields
        BufferedStream m_data;
        #endregion
    }
}
